package com.wang.learn.postgres.controller;

import com.wang.learn.postgres.entity.Book;
import com.wang.learn.postgres.service.BookService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Wang
 * @description
 * @create 2022-02-20 13:42
 */

@RestController
@RequestMapping("/book")
public class BookController {

    final BookService bookService;

    public BookController(BookService bookService) {
        this.bookService = bookService;
    }

    @RequestMapping("/add")
    public Book add(@RequestBody Book book){
        return bookService.createBook(book);
    }

    @RequestMapping("/findAll")
    public List<Book> findAll(Book book){
        return bookService.findAll(book);
    }


}
